package com.axiu;

import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.os.Bundle;
import android.os.Handler;
import android.view.KeyEvent;
import android.view.WindowManager;


public class SplashyActivity extends BaseActivity {
	private final static int DELAYED = 3000;
	private SharedPreferences f;
	private Editor edit;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		this.setContentView(R.layout.splashy);

		 addShortcut();
		getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
				WindowManager.LayoutParams.FLAG_FULLSCREEN);
		new Handler().postDelayed(new Runnable() {
			public void run() {
				start();
			}
		}, DELAYED);
	}

	@Override
	public boolean onKeyUp(int keyCode, KeyEvent event) {
		if (keyCode == KeyEvent.KEYCODE_BACK) {
			return true;
		} else {
			return super.onKeyUp(keyCode, event);
		}
	}

	@Override
	public boolean onKeyDown(int keyCode, KeyEvent event) {
		if (keyCode == KeyEvent.KEYCODE_BACK) {
			return true;
		} else {
			return super.onKeyDown(keyCode, event);
		}
	}

	private void start() {
		if(true){//f.getBoolean("firstInstall", true)){
			Intent intent = new Intent();
			intent.setClass(this, PushActivity.class);
			startActivity(intent);
			finish();
			
		}else{
			Intent intent = new Intent();
			intent.setClass(this, MainActivity.class);
			startActivity(intent);
			finish();
		}
	}

	//添加快捷方式
		 public void addShortcut(){
//			 if(f.getBoolean("addShortcut", true)){
//				 Intent shortcutIntent = new Intent("com.android.launcher.action.INSTALL_SHORTCUT");
//				 //添加名称
//				 shortcutIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME,getString(R.string.app_name));
//				 shortcutIntent.putExtra("duplicate", true);
//				 Intent intent = new Intent(SplashyActivity.this, SplashyActivity.class);
//				 intent.setAction("android.intent.action.MAIN");
//				 intent.addCategory("android.intent.category.LAUNCHER");
//				 //添加图标
//				 shortcutIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, Intent.ShortcutIconResource.fromContext(SplashyActivity.this,R.drawable.ic_launcher));
//				 shortcutIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, intent);
//				 sendBroadcast(shortcutIntent);
//				 edit.putBoolean("addShortcut", false);
//				 edit.commit();
//			 }else{
//
//			 }
		 }
}
